﻿Namespace data
    Friend NotInheritable Class SqlValueConverter
        Private Sub New()
        End Sub

#Region "getters based on ordinals"
        Public Shared Function GetString(ByVal reader As IDataReader, ByVal ordinal As Integer) As [String]
            If reader.IsDBNull(ordinal) Then
                Return [String].Empty
            End If
            Return reader.GetString(ordinal)
        End Function
        Public Shared Function GetInt32(ByVal reader As IDataReader, ByVal ordinal As Integer) As Integer
            If reader.IsDBNull(ordinal) Then
                Return 0
            End If
            Return Convert.ToInt32(reader.GetValue(ordinal))
        End Function
        Public Shared Function GetInt64(ByVal reader As IDataReader, ByVal ordinal As Integer) As Long
            If reader.IsDBNull(ordinal) Then
                Return 0
            End If
            Return Convert.ToInt64(reader.GetValue(ordinal))
        End Function
        Public Shared Function GetDateTime(ByVal reader As IDataReader, ByVal ordinal As Integer) As DateTime
            If reader.IsDBNull(ordinal) Then
                Return DateTime.MinValue
            End If
            Return Convert.ToDateTime(reader.GetValue(ordinal))
        End Function
#End Region

    End Class
End Namespace
